import paramiko


class SSHUtil():
    ssh = None

    def __init__(self, ip, username, password):
        SSHUtil.ssh = paramiko.SSHClient()
        know_host = paramiko.AutoAddPolicy()
        SSHUtil.ssh.set_missing_host_key_policy(know_host)
        try:
            SSHUtil.ssh.connect(
                hostname=ip,
                port=22,
                username=username,
                password=password)
        except:
            raise Exception

    @staticmethod
    def getSSHClient():
        if SSHUtil.ssh is None:
            raise Exception()
        else:
            return SSHUtil.ssh
